package com.example.demo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
//@Component
@Slf4j
@Order(3)
public class TestAspect {
    @Pointcut("execution(* com.example.demo.controller.*.*(..))")
    public void point(){}
    @Around("point()")
    public Object around(ProceedingJoinPoint s) throws Throwable {
        log.info("around: 方法之前");
        Object proceed = s.proceed();
        log.info("around: 方法执行之后");
        return proceed;
    }

    @Before("point()")
    public void before()  {
        log.info("before: 方法之前");
    }


    @After("point()")
    public void after()  {
        log.info("after: 方法执行之后");
    }

    @AfterThrowing("execution(* com.example.demo.controller.*.*(..))")
    public void afterThrowing()  {
        log.info("afterThrowing: 方法执行之后");
    }

    @AfterReturning("execution(* com.example.demo.controller.*.*(..))")
    public void afterReturning()  {
        log.info("afterReturning: 方法执行之后");
    }

}
